Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
G4InteractorMessenger Class Reference

#include <G4InteractorMessenger.hh>

Inheritance diagram for G4InteractorMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4InteractorMessenger (G4VInteractiveSession *session)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
virtual ~G4InteractorMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Attributes

G4UIcommandaddButton
 
G4UIcommandaddIcon
 
G4UIcommandaddMenu
 
G4UIcommandclearMenu
 
G4UIcommanddefaultIcons
 
G4UIdirectoryinteractorDirectory
 
G4UIcommandnativeMenu
 
G4UIcommandoutputStyle
 
G4VInteractiveSessionsession
 
G4UIcommandsys
 

Detailed Description

Definition at line 37 of file G4InteractorMessenger.hh.

Constructor & Destructor Documentation

◆ G4InteractorMessenger()

G4InteractorMessenger::G4InteractorMessenger ( G4VInteractiveSession session)

Definition at line 42 of file G4InteractorMessenger.cc.

45{
46 session = a_session;
47
48 G4UIparameter* parameter;
49
51 interactorDirectory->SetGuidance("UI interactors commands.");
52
53 // /gui/addMenu :
54 addMenu = new G4UIcommand("/gui/addMenu",this);
55 addMenu->SetGuidance("Add a menu to menu bar.");
56 parameter = new G4UIparameter("Name",'s',false);
57 parameter->SetDefaultValue("dummy");
58 addMenu->SetParameter (parameter);
59 parameter = new G4UIparameter("Label",'s',false);
60 parameter->SetDefaultValue("dummy");
61 addMenu->SetParameter (parameter);
62
63 // /gui/addButton :
64 addButton = new G4UIcommand("/gui/addButton",this);
65 addButton->SetGuidance("Add a button to menu.");
66 parameter = new G4UIparameter("Menu",'s',false);
67 parameter->SetDefaultValue("dummy");
68 addButton->SetParameter (parameter);
69 parameter = new G4UIparameter("Label",'s',false);
70 parameter->SetDefaultValue("dummy");
71 addButton->SetParameter (parameter);
72 parameter = new G4UIparameter("Command",'s',false);
73 parameter->SetDefaultValue("");
74 addButton->SetParameter (parameter);
75
76 // /gui/defaultIcons :
77 defaultIcons = new G4UIcommand("/gui/defaultIcons",this);
78 defaultIcons->SetGuidance("Set the Geant4 defaults icons in Qt driver.");
79 defaultIcons->SetGuidance("By default, Geant4 icons are enable.");
80
81 parameter = new G4UIparameter("bool",'b',true);
82 parameter->SetDefaultValue("true");
83 defaultIcons->SetParameter (parameter);
84
85 // /gui/addIcon :
86 addIcon = new G4UIcommand("/gui/addIcon",this);
88 ("Add a non-checkable icon to the Icon toolbar.");
90 ("If the Icon parameter is set to \"user_icon\", you should provide the icon file in xpm format, otherwise you have to choose one of the candidate icons");
92 ("A command given without parameters will display a window that will allow one to choose the parameters (if needed) for this command.");
94 ("E.g: /gui/addIcon \"Change background color\" user_icon /vis/viewer/set/background ../Images/background.xpm");
96 ("Special cases for the Icon parameter:");
98 (" - open: Open an open-file-selector that can run the Command with File as argument.");
100 (" - save: Open a save-file-selector that can run the Command with File as argument.");
102 (" - move/rotate/pick/zoom_in/zoom_out: Theses icons are radio-button icons that can change cursor action.");
104 (" - wireframe/solid/hidden_line_removal/hidden_line_and_surface_removal: These icons are radio-button icons that can change drawing style.");
106 (" - perspective/ortho: These icons are radio-button icons that can change projection style.");
107
108 parameter = new G4UIparameter("Label",'s',false);
109 parameter->SetDefaultValue("");
110 addIcon->SetParameter (parameter);
111
112 parameter = new G4UIparameter("Icon",'s',false);
113 parameter->SetDefaultValue("");
114 parameter->SetParameterCandidates
115 ("open save move rotate pick zoom_in zoom_out wireframe solid hidden_line_removal hidden_line_and_surface_removal perspective ortho exit user_icon");
116 addIcon->SetParameter (parameter);
117
118 parameter = new G4UIparameter("Command",'s',true);
119 parameter->SetDefaultValue("no_command");
120 addIcon->SetParameter (parameter);
121
122 parameter = new G4UIparameter("File",'s',true);
123 parameter->SetDefaultValue("no_file");
124 addIcon->SetParameter (parameter);
125
126 // /gui/system :
127 sys = new G4UIcommand("/gui/system",this);
128 sys->SetGuidance("Send a command to the system.");
129 parameter = new G4UIparameter("Command",'s',false);
130 parameter->SetDefaultValue("");
131 sys->SetParameter (parameter);
132
133 // /gui/outputStyle :
134 outputStyle = new G4UIcommand("/gui/outputStyle",this);
135 outputStyle->SetGuidance("Set output style.");
136 outputStyle->SetGuidance("Highlights commands if requested and if /control/verbose > 0.");
137 parameter = new G4UIparameter("destination",'s',true); // Omitable
138 parameter->SetParameterCandidates("cout cerr warnings errors all");
139 parameter->SetDefaultValue("all");
140 outputStyle->SetParameter (parameter);
141 parameter = new G4UIparameter("type",'s',true); // Omitable
142 parameter->SetParameterCandidates("fixed proportional");
143 parameter->SetDefaultValue("fixed");
144 outputStyle->SetParameter (parameter);
145 parameter = new G4UIparameter("highlight",'s',true); // Omitable
146 parameter->SetParameterCandidates("highlight no-highlight");
147 parameter->SetDefaultValue("highlight");
148 outputStyle->SetParameter (parameter);
149
150 // /gui/nativeMenuBar :
151 nativeMenu = new G4UIcommand("/gui/nativeMenuBar",this);
152 nativeMenu->SetGuidance("Allow native menu bar in Geant4 Qt driver.");
153 nativeMenu->SetGuidance("By default, enable.");
154
155 parameter = new G4UIparameter("bool",'b',true);
156 parameter->SetDefaultValue("true");
157 nativeMenu->SetParameter (parameter);
158 // /gui/clearMenu
159 clearMenu = new G4UIcommand("/gui/clearMenu",this);
160 clearMenu->SetGuidance("Clear menu bar, remove all user defined menu entries.");
161}
G4UIdirectory * interactorDirectory
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetDefaultValue(const char *theDefaultValue)
void SetParameterCandidates(const char *theString)

References addButton, addIcon, addMenu, clearMenu, defaultIcons, interactorDirectory, nativeMenu, outputStyle, G4UIparameter::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIparameter::SetParameterCandidates(), and sys.

◆ ~G4InteractorMessenger()

G4InteractorMessenger::~G4InteractorMessenger ( )
virtual

Definition at line 163 of file G4InteractorMessenger.cc.

164{
165 delete clearMenu;
166 delete nativeMenu;
167 delete outputStyle;
168 delete sys;
169 delete defaultIcons;
170 delete addIcon;
171 delete addButton;
172 delete addMenu;
173 delete interactorDirectory;
174}

References addButton, addIcon, addMenu, clearMenu, defaultIcons, interactorDirectory, nativeMenu, outputStyle, and sys.

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4UImessenger::GetCurrentValue ( G4UIcommand command)
virtualinherited

Reimplemented in G4ScoreQuantityMessenger, G4VisCommandModelCreate< Factory >, G4VisCommandListManagerList< Manager >, G4VisCommandListManagerSelect< Manager >, G4VisCommandManagerMode< Manager >, G4ToolsAnalysisMessenger, G4ScoringMessenger, G4EvManMessenger, G4GeneralParticleSourceMessenger, G4ParticleGunMessenger, G4GeometryMessenger, G4GenericMessenger, G4UIcontrolMessenger, GFlashShowerModelMessenger, G4DecayTableMessenger, G4ParticleMessenger, G4ParticlePropertyMessenger, G4tgrMessenger, G4PersistencyCenterMessenger, G4ProductionCutsTableMessenger, G4SchedulerMessenger, G4VITSteppingVerbose, G4MoleculeShootMessenger, G4MoleculeGunMessenger, G4ProcessManagerMessenger, G4ProcessTableMessenger, G4MatScanMessenger, G4RunMessenger, G4UserPhysicsListMessenger, G4TrackingMessenger, G4GMocrenMessenger, G4HepRepMessenger, G4VisCommandAbortReviewKeptEvents, G4VisCommandDrawOnlyToBeKeptEvents, G4VisCommandEnable, G4VisCommandList, G4VisCommandReviewKeptEvents, G4VisCommandVerbose, G4VisCommandGeometryList, G4VisCommandGeometryRestore, G4VisCommandGeometrySetColour, G4VisCommandGeometrySetDaughtersInvisible, G4VisCommandGeometrySetForceAuxEdgeVisible, G4VisCommandGeometrySetForceCloud, G4VisCommandGeometrySetForceSolid, G4VisCommandGeometrySetForceLineSegmentsPerCircle, G4VisCommandGeometrySetForceWireframe, G4VisCommandGeometrySetLineStyle, G4VisCommandGeometrySetLineWidth, G4VisCommandGeometrySetVisibility, G4VisCommandSceneActivateModel, G4VisCommandSceneCreate, G4VisCommandSceneEndOfEventAction, G4VisCommandSceneEndOfRunAction, G4VisCommandSceneList, G4VisCommandSceneNotifyHandlers, G4VisCommandSceneRemoveModel, G4VisCommandSceneSelect, G4VisCommandSceneShowExtents, G4VisCommandSceneAddArrow, G4VisCommandSceneAddArrow2D, G4VisCommandSceneAddAxes, G4VisCommandSceneAddDate, G4VisCommandSceneAddDigis, G4VisCommandSceneAddEventID, G4VisCommandSceneAddExtent, G4VisCommandSceneAddElectricField, G4VisCommandSceneAddFrame, G4VisCommandSceneAddGPS, G4VisCommandSceneAddGhosts, G4VisCommandSceneAddHits, G4VisCommandSceneAddLine, G4VisCommandSceneAddLine2D, G4VisCommandSceneAddLocalAxes, G4VisCommandSceneAddLogicalVolume, G4VisCommandSceneAddLogo, G4VisCommandSceneAddLogo2D, G4VisCommandSceneAddMagneticField, G4VisCommandSceneAddPSHits, G4VisCommandSceneAddScale, G4VisCommandSceneAddText, G4VisCommandSceneAddText2D, G4VisCommandSceneAddTrajectories, G4VisCommandSceneAddUserAction, G4VisCommandSceneAddVolume, G4VisCommandSceneAddPlotter, G4VisCommandSceneHandlerAttach, G4VisCommandSceneHandlerCreate, G4VisCommandSceneHandlerList, G4VisCommandSceneHandlerSelect, G4VisCommandSetArrow3DLineSegmentsPerCircle, G4VisCommandSetColour, G4VisCommandSetExtentForField, G4VisCommandSetLineWidth, G4VisCommandSetTextColour, G4VisCommandSetTextLayout, G4VisCommandSetTextSize, G4VisCommandSetTouchable, G4VisCommandSetVolumeForField, G4VisCommandsTouchable, G4VisCommandsTouchableSet, G4VisCommandViewerAddCutawayPlane, G4VisCommandViewerCentreOn, G4VisCommandViewerChangeCutawayPlane, G4VisCommandViewerClear, G4VisCommandViewerClearCutawayPlanes, G4VisCommandViewerClearTransients, G4VisCommandViewerClearVisAttributesModifiers, G4VisCommandViewerClone, G4VisCommandViewerColourByDensity, G4VisCommandViewerCopyViewFrom, G4VisCommandViewerCreate, G4VisCommandViewerDolly, G4VisCommandViewerFlush, G4VisCommandViewerInterpolate, G4VisCommandViewerList, G4VisCommandViewerPan, G4VisCommandViewerReset, G4VisCommandViewerRefresh, G4VisCommandViewerRebuild, G4VisCommandViewerSave, G4VisCommandViewerScale, G4VisCommandViewerSelect, G4VisCommandViewerUpdate, G4VisCommandViewerZoom, G4VisCommandViewerDefaultHiddenEdge, G4VisCommandViewerDefaultStyle, G4VisCommandsViewerSet, G4VModelCommand< T >, G4VModelCommand< M >, G4RTMessenger, G4ASCIITreeMessenger, G4VtkMessenger, G4PolarizationMessenger, and G4DNAChemistryManager.

Definition at line 58 of file G4UImessenger.cc.

59{
60 G4String nullString;
61 return nullString;
62}

Referenced by G4UIcommand::DoIt(), and G4UIcommand::GetCurrentValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

void G4InteractorMessenger::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 176 of file G4InteractorMessenger.cc.

180{
181 int paramn = command->GetParameterEntries();
182 G4String* params = new G4String [paramn];
183 if(GetValues(newValue,paramn,params)==true) {
184 if(command==addMenu) {
185 session->AddMenu((const char*)params[0],(const char*)params[1]);
186 } else if(command==addButton) {
187 session->AddButton((const char*)params[0],(const char*)params[1],(const char*)params[2]);
188 } else if(command==addIcon) {
189 session->AddIcon((const char*)params[0],(const char*)params[1],(const char*)params[2],(const char*)params[3]);
190 } else if(command==defaultIcons) {
191 session->DefaultIcons(command->ConvertToBool(newValue));
192 } else if(command==sys) {
193 int rc = system((const char*)params[0]);
194 if ( rc < 0 ){ }
195 } else if(command==outputStyle) {
196 session->OutputStyle((const char*)params[0],(const char*)params[1],(const char*)params[2]);
197 } else if(command==nativeMenu) {
198 session->NativeMenu(command->ConvertToBool(newValue));
199 } else if(command==clearMenu) {
200 session->ClearMenu();
201 }
202 }
203 delete [] params;
204}
static G4bool GetValues(G4String, int, G4String *)
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:545

References addButton, addIcon, addMenu, clearMenu, G4UIcommand::ConvertToBool(), defaultIcons, G4UIcommand::GetParameterEntries(), GetValues(), nativeMenu, outputStyle, and sys.

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ addButton

G4UIcommand* G4InteractorMessenger::addButton
private

◆ addIcon

G4UIcommand* G4InteractorMessenger::addIcon
private

◆ addMenu

G4UIcommand* G4InteractorMessenger::addMenu
private

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ clearMenu

G4UIcommand* G4InteractorMessenger::clearMenu
private

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ defaultIcons

G4UIcommand* G4InteractorMessenger::defaultIcons
private

◆ interactorDirectory

G4UIdirectory* G4InteractorMessenger::interactorDirectory
private

Definition at line 45 of file G4InteractorMessenger.hh.

Referenced by G4InteractorMessenger(), and ~G4InteractorMessenger().

◆ nativeMenu

G4UIcommand* G4InteractorMessenger::nativeMenu
private

◆ outputStyle

G4UIcommand* G4InteractorMessenger::outputStyle
private

◆ session

G4VInteractiveSession* G4InteractorMessenger::session
private

Definition at line 44 of file G4InteractorMessenger.hh.

◆ sys

G4UIcommand* G4InteractorMessenger::sys
private

The documentation for this class was generated from the following files: