Import Geant4 9.4.0 source tree
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4intercoms
|
||||
# Package: Geant4.src.G4intercoms
|
||||
#
|
||||
# CMakeLists.txt for single level library that may be build global or granular
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: CMakeLists.txt,v 1.1 2010/09/29 18:45:14 bmorgan Exp $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
include(Geant4MacroLibraryTargets)
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
|
||||
else()
|
||||
GEANT4_GLOBAL_LIBRARY_TARGET(COMPONENTS sources.cmake)
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.77 2009/11/06 09:00:02 kmura Exp $
|
||||
$Id: History,v 1.83 2010/11/11 11:32:08 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,29 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
11 November, 2010 G. Cosmo (intercoms-V09-03-04)
|
||||
- Corrected printout spelling in G4UIbatch.
|
||||
|
||||
24 August, 2010 M. Asai (intercoms-V09-03-03)
|
||||
- Add new commands
|
||||
/control/if
|
||||
/control/add
|
||||
/control/subtract
|
||||
/control/multiply
|
||||
/control/divide
|
||||
|
||||
3 Aug. 2010 K. Murakami (intercoms-V09-03-02)
|
||||
- Range check of UI commands care for units.
|
||||
* G4UIcommahd::DoIt() method is changed to virtual.
|
||||
* G4UIcmdWithADoubleAndUnit/G4UIcmdWith3VectorAndUnit: add DoIt() method.
|
||||
|
||||
19 May 2010 L. Garnier (intercoms-V09-03-01)
|
||||
- G4UIManager : Add field to get GUI Window session
|
||||
|
||||
18 May, 2010 K.Murakami (intercoms-V09-03-00)
|
||||
- add used characters to tokenNum in G4UItokenNum
|
||||
for suppressing compiler warnings of gcc 4.5
|
||||
|
||||
6 November, 2009 K. Murakami (intercoms-V09-02-02)
|
||||
- add GetPreviousSession() in G4UIbatch
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.hh,v 1.8 2006/06/29 19:07:49 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.hh,v 1.9 2010/08/03 07:10:09 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -47,6 +47,7 @@ class G4UIcmdWith3VectorAndUnit : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
virtual G4int DoIt(G4String parameterList);
|
||||
static G4ThreeVector GetNew3VectorValue(const char* paramString);
|
||||
// Convert string which represents three double values and a unit to
|
||||
// G4ThreeVector. Values are converted to the Geant4 internal unit.
|
||||
@@ -73,7 +74,7 @@ class G4UIcmdWith3VectorAndUnit : public G4UIcommand
|
||||
// the value(s) when he/she applies the command. If "omittable" is false,
|
||||
// the user must supply all three values.
|
||||
// "currentAsDefault" flag is valid only if "omittable" is true. If this
|
||||
// flag is true, the current values are used as the default values when the
|
||||
// flag is true, the current values are used as the default values when the
|
||||
// user ommit some of the parameters. If this flag is false, the values
|
||||
// given by the next SetDefaultValue() method are used.
|
||||
void SetDefaultValue(G4ThreeVector defVal);
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.hh,v 1.8 2006/06/29 19:07:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.hh,v 1.9 2010/08/03 07:10:09 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -45,7 +45,8 @@ class G4UIcmdWithADoubleAndUnit : public G4UIcommand
|
||||
G4UIcmdWithADoubleAndUnit
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
// and the pointer to the messenger must be given.
|
||||
virtual G4int DoIt(G4String parameterList);
|
||||
static G4double GetNewDoubleValue(const char* paramString);
|
||||
// Convert string which represents a double value and a unit to
|
||||
// double. Value is converted to the Geant4 internal unit.
|
||||
@@ -72,7 +73,7 @@ class G4UIcmdWithADoubleAndUnit : public G4UIcommand
|
||||
// the value when he/she applies the command. If "omittable" is false,
|
||||
// the user must supply a value.
|
||||
// "currentAsDefault" flag is valid only if "omittable" is true. If this
|
||||
// flag is true, the current value is used as the default value when the
|
||||
// flag is true, the current value is used as the default value when the
|
||||
// user ommit the double parameter. If this flag is false, the value
|
||||
// given by the next SetDefaultValue() method is used.
|
||||
void SetDefaultValue(G4double defVal);
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommand.hh,v 1.15 2006/06/29 19:08:05 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcommand.hh,v 1.16 2010/08/03 07:10:09 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef G4UIcommand_h
|
||||
#define G4UIcommand_h 1
|
||||
@@ -41,7 +41,7 @@ class G4UImessenger;
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
//
|
||||
// This G4UIcommand is the "concrete" base class which represents a command
|
||||
// used by Geant4 (G)UI. The user can use this class in case the parameter
|
||||
// arguments of a command are not suitable with respect to the derived command
|
||||
@@ -49,21 +49,21 @@ class G4UImessenger;
|
||||
// Some methods defined in this base class are used by the derived classes.
|
||||
//
|
||||
|
||||
class G4UIcommand
|
||||
class G4UIcommand
|
||||
{
|
||||
public:
|
||||
public:
|
||||
G4UIcommand();
|
||||
public: // with description
|
||||
G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
public:
|
||||
public:
|
||||
virtual ~G4UIcommand();
|
||||
|
||||
G4int operator==(const G4UIcommand &right) const;
|
||||
G4int operator!=(const G4UIcommand &right) const;
|
||||
|
||||
G4int DoIt(G4String parameterList);
|
||||
virtual G4int DoIt(G4String parameterList);
|
||||
G4String GetCurrentValue();
|
||||
public: // with description
|
||||
void AvailableForStates(G4ApplicationState s1);
|
||||
@@ -107,7 +107,7 @@ class G4UIcommand
|
||||
static G4String UnitsList(const char* unitCategory);
|
||||
// Static methods for unit and its category.
|
||||
|
||||
private:
|
||||
private:
|
||||
void G4UIcommandCommonConstructorCode (const char * theCommandPath);
|
||||
G4UImessenger *messenger;
|
||||
G4String commandPath;
|
||||
@@ -145,16 +145,16 @@ class G4UIcommand
|
||||
public: // with description
|
||||
inline void SetParameter(G4UIparameter *const newParameter)
|
||||
{
|
||||
parameter.push_back( newParameter );
|
||||
newVal.resize( parameter.size() );
|
||||
parameter.push_back( newParameter );
|
||||
newVal.resize( parameter.size() );
|
||||
}
|
||||
// Defines a parameter. This method is used by the derived command classes
|
||||
// but the user can directly use this command when he/she defines a command
|
||||
// by hem(her)self without using the derived class. For this case, the order
|
||||
// of the parameters is the order of invoking this method.
|
||||
inline void SetGuidance(const char * aGuidance)
|
||||
{
|
||||
commandGuidance.push_back( G4String( aGuidance ) );
|
||||
{
|
||||
commandGuidance.push_back( G4String( aGuidance ) );
|
||||
}
|
||||
// Adds a guidance line. Unlimitted number of invokation of this method is
|
||||
// allowed. The given lines of guidance will appear for the help. The first
|
||||
@@ -163,10 +163,10 @@ class G4UIcommand
|
||||
public:
|
||||
inline const G4String GetTitle() const
|
||||
{
|
||||
if(commandGuidance.size() == 0)
|
||||
{ return G4String("...Title not available..."); }
|
||||
else
|
||||
{ return commandGuidance[0]; }
|
||||
if(commandGuidance.size() == 0)
|
||||
{ return G4String("...Title not available..."); }
|
||||
else
|
||||
{ return commandGuidance[0]; }
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -193,12 +193,12 @@ class G4UIcommand
|
||||
G4int Eval2( yystype arg1, G4int op, yystype arg2 );
|
||||
G4int CompareInt( G4int arg1, G4int op, G4int arg2);
|
||||
G4int CompareDouble( G4double arg1, G4int op, G4double arg2);
|
||||
// utility
|
||||
// utility
|
||||
tokenNum Yylex( void ); // returns next token
|
||||
unsigned IndexOf( const char* ); // returns the index of the var name
|
||||
unsigned IsParameter( const char* ); // returns 1 or 0
|
||||
G4int G4UIpGetc( void ); // read one char from rangeBuf
|
||||
G4int G4UIpUngetc( G4int c ); // put back
|
||||
G4int G4UIpUngetc( G4int c ); // put back
|
||||
G4int Backslash( G4int c );
|
||||
G4int Follow( G4int expect, G4int ifyes, G4int ifno );
|
||||
G4String TokenToStr(G4int token);
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcontrolMessenger.hh,v 1.12 2007/06/06 15:14:51 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcontrolMessenger.hh,v 1.13 2010/08/25 06:09:57 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
|
||||
#ifndef G4UIcontrolMessenger_h
|
||||
@@ -60,6 +60,11 @@ class G4UIcommand;
|
||||
// /control/manual
|
||||
// /control/createHTML
|
||||
// /control/maximumStoredHistory
|
||||
// /control/if
|
||||
// /control/add
|
||||
// /control/subtract
|
||||
// /control/multiply
|
||||
// /control/divide
|
||||
|
||||
class G4UIcontrolMessenger : public G4UImessenger
|
||||
{
|
||||
@@ -87,6 +92,12 @@ class G4UIcontrolMessenger : public G4UImessenger
|
||||
G4UIcmdWithAString * ManualCommand;
|
||||
G4UIcmdWithAString * HTMLCommand;
|
||||
G4UIcmdWithAnInteger * maxStoredHistCommand;
|
||||
G4UIcommand * ifCommand;
|
||||
G4UIcommand * addCommand;
|
||||
G4UIcommand * subtractCommand;
|
||||
G4UIcommand * multiplyCommand;
|
||||
G4UIcommand * divideCommand;
|
||||
G4UIcommand * remainderCommand;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UImanager.hh,v 1.21 2006/06/29 19:08:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UImanager.hh,v 1.22 2010/05/19 14:50:30 lgarnier Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04-beta-01 $
|
||||
//
|
||||
|
||||
#ifndef G4UImanager_h
|
||||
@@ -143,6 +143,7 @@ class G4UImanager : public G4VStateDependent
|
||||
static G4bool fUImanagerHasBeenKilled;
|
||||
G4UIcommandTree * treeTop;
|
||||
G4UIsession * session;
|
||||
G4UIsession * g4UIWindow;
|
||||
G4UIcontrolMessenger * UImessenger;
|
||||
G4UnitsMessenger * UnitsMessenger;
|
||||
G4String savedParameters;
|
||||
@@ -197,9 +198,13 @@ class G4UImanager : public G4VStateDependent
|
||||
{ return treeTop; }
|
||||
inline G4UIsession * GetSession() const
|
||||
{ return session; }
|
||||
inline G4UIsession * GetG4UIWindow() const
|
||||
{ return g4UIWindow; }
|
||||
public: // with description
|
||||
inline void SetSession(G4UIsession *const value)
|
||||
{ session = value; }
|
||||
inline void SetG4UIWindow(G4UIsession *const value)
|
||||
{ g4UIWindow = value; }
|
||||
// This method defines the active (G)UI session.
|
||||
void SetCoutDestination(G4UIsession *const value);
|
||||
// This method defines the destination of G4cout/G4cerr stream.
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UItokenNum.hh,v 1.8 2006/06/29 19:08:25 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UItokenNum.hh,v 1.9 2010/05/18 07:46:29 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04-beta-01 $
|
||||
//
|
||||
// G4UItokenNum.hh
|
||||
|
||||
@@ -49,7 +49,11 @@ enum tokenNum
|
||||
NE = 267,
|
||||
//LOGICALNOT = 268,
|
||||
LOGICALOR = 269,
|
||||
LOGICALAND = 270
|
||||
LOGICALAND = 270,
|
||||
SCAREAMER = 33,
|
||||
LPAREN = 40,
|
||||
PLUS = 43,
|
||||
MINUS = 45
|
||||
};
|
||||
|
||||
|
||||
@@ -83,5 +87,5 @@ typedef struct yystype
|
||||
*this=right;
|
||||
}
|
||||
} yystype;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# sources.cmake
|
||||
# Module : G4intercoms
|
||||
# Package: Geant4.src.G4intercoms
|
||||
#
|
||||
# Sources description for a library.
|
||||
# Lists the sources and headers of the code explicitely.
|
||||
# Lists include paths needed.
|
||||
# Lists the internal granular and global dependencies of the library.
|
||||
# Source specific properties should be added at the end.
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: sources.cmake,v 1.1 2010/09/29 18:45:22 bmorgan Exp $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# List external includes needed.
|
||||
include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
|
||||
# List internal includes needed.
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
|
||||
|
||||
#
|
||||
# Define the Geant4 Module.
|
||||
#
|
||||
include(Geant4MacroDefineModule)
|
||||
GEANT4_DEFINE_MODULE(NAME G4intercoms
|
||||
HEADERS
|
||||
G4UIaliasList.hh
|
||||
G4UIbatch.hh
|
||||
G4UIcmdWith3Vector.hh
|
||||
G4UIcmdWith3VectorAndUnit.hh
|
||||
G4UIcmdWithABool.hh
|
||||
G4UIcmdWithADouble.hh
|
||||
G4UIcmdWithADoubleAndUnit.hh
|
||||
G4UIcmdWithAString.hh
|
||||
G4UIcmdWithAnInteger.hh
|
||||
G4UIcmdWithoutParameter.hh
|
||||
G4UIcommand.hh
|
||||
G4UIcommandStatus.hh
|
||||
G4UIcommandTree.hh
|
||||
G4UIcontrolMessenger.hh
|
||||
G4UIdirectory.hh
|
||||
G4UImanager.hh
|
||||
G4UImessenger.hh
|
||||
G4UIparameter.hh
|
||||
G4UIsession.hh
|
||||
G4UItokenNum.hh
|
||||
G4UnitsMessenger.hh
|
||||
G4VFlavoredParallelWorld.hh
|
||||
G4VGlobalFastSimulationManager.hh
|
||||
SOURCES
|
||||
G4UIaliasList.cc
|
||||
G4UIbatch.cc
|
||||
G4UIcmdWith3Vector.cc
|
||||
G4UIcmdWith3VectorAndUnit.cc
|
||||
G4UIcmdWithABool.cc
|
||||
G4UIcmdWithADouble.cc
|
||||
G4UIcmdWithADoubleAndUnit.cc
|
||||
G4UIcmdWithAString.cc
|
||||
G4UIcmdWithAnInteger.cc
|
||||
G4UIcmdWithoutParameter.cc
|
||||
G4UIcommand.cc
|
||||
G4UIcommandTree.cc
|
||||
G4UIcontrolMessenger.cc
|
||||
G4UIdirectory.cc
|
||||
G4UImanager.cc
|
||||
G4UImessenger.cc
|
||||
G4UIparameter.cc
|
||||
G4UIsession.cc
|
||||
G4UnitsMessenger.cc
|
||||
G4VGlobalFastSimulationManager.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4globman
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4global
|
||||
LINK_LIBRARIES
|
||||
)
|
||||
|
||||
# List any source specific properties here
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4UIbatch.cc,v 1.17 2008/11/21 10:54:16 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIbatch.cc,v 1.18 2010/11/11 11:30:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4UIbatch.cc
|
||||
@@ -211,7 +211,7 @@ G4UIsession * G4UIbatch::SessionStart()
|
||||
// execute command
|
||||
G4int rc= ExecCommand(newCommand);
|
||||
if(rc != fCommandSucceeded) {
|
||||
G4cerr << G4endl << "***** Batch is interupted!! *****" << G4endl;
|
||||
G4cerr << G4endl << "***** Batch is interrupted!! *****" << G4endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.9 2006/06/29 19:08:41 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.10 2010/08/03 07:10:47 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -49,6 +49,44 @@ G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit
|
||||
untParam->SetParameterName("Unit");
|
||||
}
|
||||
|
||||
G4int G4UIcmdWith3VectorAndUnit::DoIt(G4String parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer token(parameterList);
|
||||
G4String str;
|
||||
while( (str = token()) != "" ) {
|
||||
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) {
|
||||
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;
|
||||
G4double z = ConvertToDouble(token_vector[2]) * value_given / value_default;
|
||||
|
||||
// reconstruct parameter list
|
||||
converted_parameter += ConvertToString(x);
|
||||
converted_parameter += " ";
|
||||
converted_parameter += ConvertToString(y);
|
||||
converted_parameter += " ";
|
||||
converted_parameter += ConvertToString(z);
|
||||
converted_parameter += " ";
|
||||
converted_parameter += default_unit;
|
||||
for ( size_t i=4 ; i< token_vector.size(); i++) {
|
||||
converted_parameter += " ";
|
||||
converted_parameter += token_vector[i];
|
||||
}
|
||||
} else {
|
||||
converted_parameter = parameterList;
|
||||
}
|
||||
|
||||
return G4UIcommand::DoIt(converted_parameter);
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(const char* paramString)
|
||||
{
|
||||
return ConvertToDimensioned3Vector(paramString);
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.9 2006/06/29 19:08:48 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.10 2010/08/03 07:10:47 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
@@ -45,6 +46,38 @@ G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit
|
||||
untParam->SetParameterName("Unit");
|
||||
}
|
||||
|
||||
G4int G4UIcmdWithADoubleAndUnit::DoIt(G4String parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer token(parameterList);
|
||||
G4String str;
|
||||
while( (str = token()) != "" ) {
|
||||
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) {
|
||||
G4double value_given = ValueOf(token_vector[1]);
|
||||
G4double value_default = ValueOf(default_unit);
|
||||
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++) {
|
||||
converted_parameter += " ";
|
||||
converted_parameter += token_vector[i];
|
||||
}
|
||||
} else {
|
||||
converted_parameter = parameterList;
|
||||
}
|
||||
|
||||
return G4UIcommand::DoIt(converted_parameter);
|
||||
}
|
||||
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(const char* paramString)
|
||||
{
|
||||
return ConvertToDimensionedDouble(paramString);
|
||||
@@ -54,10 +87,10 @@ G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue(const char* paramString
|
||||
{
|
||||
G4double vl;
|
||||
char unts[30];
|
||||
|
||||
|
||||
std::istringstream is(paramString);
|
||||
is >> vl >> unts;
|
||||
|
||||
|
||||
return vl;
|
||||
}
|
||||
|
||||
@@ -65,11 +98,11 @@ G4double G4UIcmdWithADoubleAndUnit::GetNewUnitValue(const char* paramString)
|
||||
{
|
||||
G4double vl;
|
||||
char unts[30];
|
||||
|
||||
|
||||
std::istringstream is(paramString);
|
||||
is >> vl >> unts;
|
||||
G4String unt = unts;
|
||||
|
||||
|
||||
return ValueOf(unt);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcontrolMessenger.cc,v 1.11 2007/06/06 15:14:51 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UIcontrolMessenger.cc,v 1.12 2010/08/25 06:09:57 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIaliasList.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
@@ -151,6 +153,82 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands.");
|
||||
maxStoredHistCommand->SetParameterName("max",true);
|
||||
maxStoredHistCommand->SetDefaultValue(20);
|
||||
|
||||
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);
|
||||
ifCommand->SetParameter(leftParam);
|
||||
G4UIparameter* compParam = new G4UIparameter("comp",'s',false);
|
||||
compParam->SetParameterCandidates("> >= < <= == !=");
|
||||
ifCommand->SetParameter(compParam);
|
||||
G4UIparameter* rightParam = new G4UIparameter("right",'d',false);
|
||||
ifCommand->SetParameter(rightParam);
|
||||
G4UIparameter* macroFileParam = new G4UIparameter("aliasValue",'s',false);
|
||||
ifCommand->SetParameter(macroFileParam);
|
||||
|
||||
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(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias1 = new G4UIparameter("new_alias",'s',false);
|
||||
addCommand->SetParameter(newAlias1);
|
||||
G4UIparameter* val1a = new G4UIparameter("value1",'d',false);
|
||||
addCommand->SetParameter(val1a);
|
||||
G4UIparameter* val1b = new G4UIparameter("value2",'d',false);
|
||||
addCommand->SetParameter(val1b);
|
||||
|
||||
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(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias2 = new G4UIparameter("new_alias",'s',false);
|
||||
subtractCommand->SetParameter(newAlias2);
|
||||
G4UIparameter* val2a = new G4UIparameter("value1",'d',false);
|
||||
subtractCommand->SetParameter(val2a);
|
||||
G4UIparameter* val2b = new G4UIparameter("value2",'d',false);
|
||||
subtractCommand->SetParameter(val2b);
|
||||
|
||||
multiplyCommand = new G4UIcommand("/control/multiply",this);
|
||||
multiplyCommand->SetGuidance("Define a new alias as the multiplification 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(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias3 = new G4UIparameter("new_alias",'s',false);
|
||||
multiplyCommand->SetParameter(newAlias3);
|
||||
G4UIparameter* val3a = new G4UIparameter("value1",'d',false);
|
||||
multiplyCommand->SetParameter(val3a);
|
||||
G4UIparameter* val3b = new G4UIparameter("value2",'d',false);
|
||||
multiplyCommand->SetParameter(val3b);
|
||||
|
||||
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(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias4 = new G4UIparameter("new_alias",'s',false);
|
||||
divideCommand->SetParameter(newAlias4);
|
||||
G4UIparameter* val4a = new G4UIparameter("value1",'d',false);
|
||||
divideCommand->SetParameter(val4a);
|
||||
G4UIparameter* val4b = new G4UIparameter("value2",'d',false);
|
||||
val4b->SetParameterRange("value2 != 0.");
|
||||
divideCommand->SetParameter(val4b);
|
||||
|
||||
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(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias5 = new G4UIparameter("new_alias",'s',false);
|
||||
remainderCommand->SetParameter(newAlias5);
|
||||
G4UIparameter* val5a = new G4UIparameter("value1",'i',false);
|
||||
remainderCommand->SetParameter(val5a);
|
||||
G4UIparameter* val5b = new G4UIparameter("value2",'i',false);
|
||||
val4b->SetParameterRange("value2 != 0");
|
||||
remainderCommand->SetParameter(val5b);
|
||||
|
||||
}
|
||||
|
||||
G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
@@ -171,6 +249,13 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
delete foreachCommand;
|
||||
delete HTMLCommand;
|
||||
delete maxStoredHistCommand;
|
||||
delete ifCommand;
|
||||
delete addCommand;
|
||||
delete subtractCommand;
|
||||
delete multiplyCommand;
|
||||
delete divideCommand;
|
||||
delete remainderCommand;
|
||||
|
||||
delete controlDirectory;
|
||||
}
|
||||
|
||||
@@ -249,7 +334,82 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
UI->SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue));
|
||||
}
|
||||
|
||||
if(command==ifCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
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);
|
||||
}
|
||||
if(command==addCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l+r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==subtractCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l-r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==multiplyCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l*r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==divideCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l/r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==remainderCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4int l = StoI(next());
|
||||
G4int r = StoI(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l%r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UImanager.cc,v 1.33 2007/07/16 10:14:36 kmura Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UImanager.cc,v 1.34 2010/05/19 14:50:30 lgarnier Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04-beta-01 $
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -73,6 +73,7 @@ G4UImanager::G4UImanager()
|
||||
verboseLevel = 0;
|
||||
saveHistory = false;
|
||||
session = NULL;
|
||||
g4UIWindow = NULL;
|
||||
SetCoutDestination(session);
|
||||
pauseAtBeginOfEvent = false;
|
||||
pauseAtEndOfEvent = false;
|
||||
|
||||
Reference in New Issue
Block a user